package com.witframework.baseapp.security.system;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.javalid.annotations.validation.NotEmpty;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;

/**
 * The Client Deﬁnition Tab deﬁnes a unique client.Do not create a new client in this window, but use Initial Client
 * Setup (System Administrator Role) to set up the required security and access rules.
 * 
 * @author wuxinyang Jun 18, 2009 11:35:37 AM
 */
@Entity @Table(name = "AD_LOGGING")
public class SystemLog {	
	private String id ;		
	private String username; //用户ID
	private java.util.Date datetime;	//记录时间
	private String infoCode;//返回码
	private String description;	//出错描述
	private java.util.Date duration;//交易时间
	private String clientIp;	//客户端IP地址
	private String operation;//操作名称
	private String objectId;//对象ID
	private String transactionData;//处理的数据XML表示字符串
	public SystemLog(){
		
	}
	/**
	 * @param username
	 * @param datetime
	 * @param infoCode
	 * @param description
	 * @param duration
	 * @param clientIp
	 * @param operation
	 * @param objectId
	 * @param transactionData
	 */
	public SystemLog(String username, Date datetime,String infoCode, String description, Date duration, String clientIp, String operation, String objectId,
			String transactionData) {
		super();
		this.username = username;
		this.datetime = datetime;
		this.infoCode=infoCode;
		this.description = description;
		this.duration = duration;
		this.clientIp = clientIp;
		this.operation = operation;
		this.objectId = objectId;
		this.transactionData = transactionData;
	}
	@Column(length=32)@Id @GeneratedValue(generator="wit-uuid") 
	@GenericGenerator(name="wit-uuid", strategy = "com.witframework.core.WitIdentifierGenerator")
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	@Column(length = 60, nullable = false)
	@Length(max = 60)@NotEmpty
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	@Column(length = 255)
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	public java.util.Date getDatetime() {
		if(datetime==null)
			return new java.util.Date();
		return datetime;
	}
	public void setDatetime(java.util.Date datetime) {
		this.datetime = datetime;
	}	
	public java.util.Date getDuration() {
		if(duration==null)
			return new java.util.Date();
		return duration;
	}
	public void setDuration(java.util.Date duration) {
		this.duration = duration;
	}
	@Column(length = 60, nullable = false)
	public String getClientIp() {
		return clientIp;
	}
	public void setClientIp(String clientIp) {
		this.clientIp = clientIp;
	}
	@Column(length = 60, nullable = false)
	public String getOperation() {
		return operation;
	}
	public void setOperation(String operation) {
		this.operation = operation;
	}
	@Column(length = 60)
	public String getObjectId() {
		return objectId;
	}
	public void setObjectId(String objectId) {
		this.objectId = objectId;
	}
	@Column(length = 2000)
	public String getTransactionData() {
		return transactionData;
	}
	public void setTransactionData(String transactionData) {
		this.transactionData = transactionData;
	}
	@Column(length = 60)
	public String getInfoCode() {
		return infoCode;
	}
	public void setInfoCode(String infoCode) {
		this.infoCode = infoCode;
	}
	
}
